//
//  AboutViewController.m
//  ydtctz
//
//  Created by 小宝 on 1/7/12.
//  Copyright (c) 2012 Bosermobile. All rights reserved.
//

#import "AboutViewController.h"

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"关于我们";
    _aboutData = @[@"版本", @"版权"];

    [self initUI];
}

- (void)initUI {
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(5, 0, mScreenWidth-10, 400) style:UITableViewStyleGrouped];

    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollEnabled = NO;
    _tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_tableView];
    
    UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, mScreenWidth-10, 60)];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, mScreenWidth-10, 40)];
    label.text = @"技术支持：c8彩票";
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = toPCcolor(@"#a09c9c");
    label.font = [UIFont systemFontOfSize:14];
    
    [footView addSubview:label];
    [_tableView setTableFooterView:footView];
    
    // 初始化cell上的4个label
    _officialwebLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    _officialwebLabel.text = APP_VERSION;
    _officialwebLabel.textColor = toPCcolor(@"#555555");
    _officialwebLabel.font = [UIFont systemFontOfSize:14];
    _officialwebLabel.textAlignment = NSTextAlignmentRight;
    [_officialwebLabel sizeToFit];
    
    _copyrightLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    _copyrightLabel.text = @"c8彩票";
    _copyrightLabel.textColor = toPCcolor(@"#555555");
    [_copyrightLabel adjustsFontSizeToFitWidth];
    _copyrightLabel.font = [UIFont systemFontOfSize:14];
    _copyrightLabel.textAlignment = NSTextAlignmentRight;
    [_copyrightLabel sizeToFit];
}


#pragma mark  UITableView delegate && datasource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return  _aboutData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentif = @"cellIdentif";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentif];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentif];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.text = _aboutData[indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.textLabel.textColor = NAVITITLECOLOR;
    
    switch (indexPath.row) {
        case 0:
            [cell.contentView addSubview:_officialwebLabel];
            _officialwebLabel.right = tableView.right-25;
            _officialwebLabel.top = 15;
            break;
        case 1:
            [cell.contentView addSubview:_copyrightLabel];
            _copyrightLabel.right = tableView.right-25;
            _copyrightLabel.top = 15;
            break;
        default:
            break;
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

@end
